<template>
  <div>
    <el-card class="box-card">
      <div style="display: flex; justify-content: flex-end">
        <div>
          <el-button @click="$router.go(-1)" type="primary">返回</el-button>
          <el-button @click="handleRefresh()" type="danger">刷新</el-button>
        </div>
      </div>
    </el-card>
    <el-card class="box-card" style="margin-top: 10px">
      <el-table :data="dataList" border style="width: 100%; margin-top: 20px" :default-sort = "{prop: 'date', order: 'descending'}">
        <!-- <el-table-column type="index"
                         label="序号"
                         align="center"
                         width="80">
          <template slot-scope="scope">
            <span :title="scope.row.id"> {{ scope.$index + 1 }}</span>
          </template>
        </el-table-column> -->
        <el-table-column
          prop="userName"
          label="Iwork名称"
          align="center"
          width="220"
        >
          <template slot-scope="scope">
            <span> {{ scope.row.userName }}({{ scope.row.jobNo }})</span>
          </template>
        </el-table-column>
        <el-table-column
          label="推送类型"
          prop="modeType"
          width="160"
          align="center"
        >
          <template slot-scope="scope">
            <span v-if="scope.row.modeType === 'iwork'">iwork</span>
            <span v-else-if="scope.row.modeType === 'short'">短信</span>
            <span v-else>外呼</span>
          </template>
        </el-table-column>

        <el-table-column prop="isSend" label="是否推送" align="center" >
          <template slot-scope="scope">
            <span v-if="scope.row.isSend > 0">是</span>
            <span v-else-if="scope.row.isSend === 0">否</span>
          </template>
        </el-table-column>
        <el-table-column prop="sendTime" label="推送时间" align="center" sortable>
        </el-table-column>
        <!-- <el-table-column prop="isRed" label="是否外呼" align="center">
          <template slot-scope="scope">
            <span v-if="scope.row.isSend === 1 && scope.row.isAiOutbound === 1">外呼成功</span>
            <span v-else>外呼失败</span>
          </template>
        </el-table-column> -->
        <el-table-column prop="isRed" label="是否响应" align="center">
          <template slot-scope="scope">
            <div v-if="scope.row.modeType === 'ai'">
              <span
                v-if="scope.row.isSend === 1 && scope.row.isAiOutboundSus === 1">外呼成功</span>
              <span v-else>外呼失败</span>
            </div>
            <div v-if="scope.row.modeType !== 'ai'">
              <span
                v-if="scope.row.isRed === 1">是</span>
              <span v-else>否</span>
            </div>
          </template>
        </el-table-column>

        <el-table-column prop="redTime" label="响应时间" align="center" sortable>
        </el-table-column>
        <el-table-column prop="createTime" label="添加时间" align="center" sortable>
        </el-table-column>
         <el-table-column prop="content" label="内容" align="center">
        </el-table-column>
        <el-table-column prop="messageLog" label="日志" align="center">
        </el-table-column>
        <!-- <el-table-column prop="isAiOutbound" label="是否外呼" align="center">
                      <template slot-scope="scope">
            <span v-if="scope.row.isAiOutbound === 1">外呼成功</span>
            <span v-else-if="scope.row.isAiOutbound === 0">外呼失败</span>
          </template>
        </el-table-column>
        <el-table-column prop="aiOutboundTime" label="外呼时间" align="center">
        </el-table-column> -->
      </el-table>
      <!-- 分页 -->
      <!-- <Pagination :total="total"
                  :pageNum="pageNum"
                  :pageSize="pageSize"
                  @pageChange="pageChange" /> -->
    </el-card>
    <!-- 弹窗, 新增 / 修改 -->
  </div>
</template>

<script>
import axios from "axios";
export default {
  data() {
    return {
      dataList: [],
    };
  },
  created() {
    // this.fetchDetailsData();
  },
  activated() {
    this.getDataList();
  },
  methods: {
    //获取详情数据
    getDataList() {
      let jobNo = this.$route.query.jobNo;
      let logIndex = this.$route.query.logIndex;
      let linkId = this.$route.query.linkId;
      console.log(jobNo, logIndex, "11111111111");
      console.log(linkId,"linkId");
      this.$http({
        url: this.$http.adornUrl("/cpcplog/getCpcpLogList"),
        method: "post",
        data: this.$http.adornData({
          jobNo: jobNo,
          logIndex: logIndex,
          linkId:linkId
        }),
      }).then((res) => {
        console.log(res, "res");
        this.dataList = res.data.list;
        console.log(this.dataList, "dataList");
        // if (res.data.code === 0) {
        //   this.$message({
        //     message: "调用成功!",
        //     type: "success",
        //   });
        //   this.fetchTableList();
        // }
      });
    },
    getSendObject(item) {
      let str = "";
      if (item.sendGroup == 1) {
        str = item.groupName;
      } else {
        if (null != item.labelName) {
          str = item.labelName;
        } else {
          str = "个人";
        }
      }
      return str;
    },
    handleRefresh() {
      this.getDataList();
    },

    getCallReadState(item) {
      let str = "";
      if (item.leaderRed == 1) {
        str += "已响应";
        str += "</br>" + item.leaderTime + "";
      }
      return str;
    },
    getIWorkReadState(item) {
      let str = "";
      if (item.iworkRed == 1) {
        str += "已响应";
        str += "</br>" + item.iworkTime + "";
      }
      return str;
    },
    //外呼情况
    getCallState(item) {
      let str = "";
      if (item.aiIsSend == 1) {
        str += "已呼通";
        str += "</br>" + item.aiTime + "";
      } else if (item.aiIsSend == 2) {
        str += "未呼通";
      } else if (item.aiIsSend == 0) {
        str += "呼通失败";
        if (item.aiTime != null) {
          str += "</br>" + item.aiTime + "";
        }
      } else {
        str += "";
      }

      return str;
    },
    //信息推送情况
    getSmsState(item) {
      let str = "";
      if (item.shortIsSend == 1) {
        str += "已推送";
        str += "</br>" + item.shortTime + "";
      } else if (item.shortIsSend == 2) {
        str += "未推送";
        // str += "</br>" + item.shortTime + "";
      } else if (item.shortIsSend == 0) {
        str += "推送失败";
        if (item.shortTime != null) {
          str += "</br>" + item.shortTime + "";
        }
      } else {
        str += "";
      }

      return str;
    },
    //推送情况
    getIWorkState(item) {
      let str = "";
      if (item.iworkIsSend == 1) {
        str += "已推送";
        str += "</br>" + item.iworkSendTime + "";
      } else if (item.iworkIsSend == 2) {
        str += "未推送";
      } else if (item.iworkIsSend == 0) {
        str += "推送失败";
        if (item.iworkSendTime != null) {
          str += "</br>" + item.iworkSendTime + "";
        }
      } else {
        str += "";
      }

      return str;
    },
  },
};
</script>
<style scoped>
.green {
  color: green;
}
.red {
  color: red;
}
.des_con span {
  font-size: 18px;
  font-weight: 600;
}
.read {
  cursor: pointer;
  color: yellowgreen;
}
.table {
  width: 100%;
}
.table tr {
  line-height: 30px;
}
.table tr td {
  width: 50%;
}
</style>

